using System;
using System.Collections.Generic;

using IBatisNet.Common;
using IBatisNet.DataMapper;

using log4net;

using GymManager.Exception;
using GymManager.Persistence.VO;

namespace GymManager.Persistence.DAO
{
    /// <summary>
    /// Class responsible by getting information from database about expense payment
    /// </summary>
    public class ExpensePaymentDAO
    {
        // logger instance
        private ILog _logManager = LogManager.GetLogger(typeof(ExpensePaymentDAO));

        /// <summary>
        /// Method responsible by adding a new expense payment to database
        /// </summary>
        /// <param name="ExpensePayment">expense payment information to be saved</param>
        /// <see cref="GymManager.Exception.PersistenceException"/>
        public void create(ExpensePayment expensePaymentVO)
        {
            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("Begin Method");
            }

            try
            {
                ISqlMapper ibatisMapper = DAOManager.getInstance();
                ibatisMapper.Insert("ExpensePayment.insert", expensePaymentVO);
            }
            catch (System.Exception ex)
            {
                _logManager.Error("Error while saving expense payment information", ex);
                throw new PersistenceException("Error while saving expense payment information", ex);
            }

            if (_logManager.IsInfoEnabled)
            {
                _logManager.Info("End Method");
            }
        }
    }
}
